package com.example.controller;

import com.example.entity.MyResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDateTime;

/**
 * @author fyx
 */
@Controller
public class MyController {
    @RequestMapping("/")
    public String index(Model model) {
        System.out.println("myController index");
        model.addAttribute("msg", "欢迎来到mySpringBoot");
        return "index";
    }

    @RequestMapping("/getTime")
    @ResponseBody
    @CrossOrigin("http://localhost:9527")
    public MyResponseEntity<?> getTime() {
        return new MyResponseEntity<>(200,"",LocalDateTime.now().toString());
    }

    @RequestMapping("/user/Login")
    @ResponseBody
    public MyResponseEntity<?> login(){
        return new MyResponseEntity<>(200,"登录成功","aaa");
    }
}
